//package cn.edu.zsc.study.framework.security;
//
//import cn.edu.zsc.study.framework.JsonExceptionUtil;
//import lombok.AllArgsConstructor;
//import org.springframework.http.HttpStatus;
//import org.springframework.security.core.Authentication;
//import org.springframework.security.core.context.SecurityContextHolder;
//import org.springframework.security.web.authentication.AuthenticationSuccessHandler;
//import org.springframework.stereotype.Component;
//
//import javax.servlet.http.HttpServletRequest;
//import javax.servlet.http.HttpServletResponse;
//import java.time.LocalDateTime;
//import java.util.Map;
//
///**
// * @author harry_yao
// */
//@AllArgsConstructor
//@Component
//public class CustomAuthenticationSuccessHandler implements AuthenticationSuccessHandler {
//
//    @Override
//    public void onAuthenticationSuccess(HttpServletRequest request, HttpServletResponse response, Authentication authentication) {
//        Object principal = SecurityContextHolder.getContext().getAuthentication().getPrincipal();
//        response.setStatus(HttpStatus.UNAUTHORIZED.value());
//        response.setContentType("application/json;charset=utf-8");
//        Map<String, Object> exceptionMap = JsonExceptionUtil.jsonExceptionResult(
//                HttpStatus.UNAUTHORIZED,
//                "会话已过期 (也可能是从其它终端登录了).",
//                "/api/rest/**"
//        );
//        response.getWriter().print(objectMapper.writeValueAsString(exceptionMap));
//        response.flushBuffer();
//
//    }
//
//}
